var redirect = 'redirect';

function isLogin(callback) {
    $.ajax({
        url: baseloaction +'/mobile/user/isLogin',
        type:'post',
        dataType:'json',
        success:function (result) {
            if(result.entity==false){//未登录则跳转登录页面
                window.location.href=baseloaction +'/mobile/user/login';
            }else{//如果已登录，则回调
                if($.isFunction(callback)){
                    callback();
                }
            }
        },
        error:function (error) {
            $.toast('系统错误，验证登录失败');
        }
    });
}

/**
 * 获取跳转路径
 */
function redirectURL(_url_) {
    var url = getCookie(redirect);
    if(url !=null && $.trim(url)!=''){
        window.location.replace(url);
        DeleteCookie(redirect);
        return;
    }
    window.location.replace(_url_);
}

/**
 * 登录判断接口
 * @param callback
 */
function isLoginStatus() {
    var status = false;
    $.ajax({
        url:baseloaction +'/mobile/user/isLogin',
        type:'post',
        dataType:'json',
        async:false,
        data:{},
        success:function (result) {
            status = result.entity;
        }
    });
    return status;
}
